﻿using System;
using System.Collections.ObjectModel;
using System.Linq;
using System.Runtime.Serialization;

namespace Core.Model.Hierarchy
{
    [DataContract]
    public class Project
    {
        [DataMember]
        public string Name { get; set; }

        [DataMember]
        public string Description { get; set; }

        [DataMember]
        public string Path { get; set; }

        public Research CurrentResearch { get; set; }

        [DataMember]
        public ObservableCollection<Tuple<string,string>> CustomInformation { get; set; }

        [DataMember]
        public ObservableCollection<Research> Researches { get; set; }

	    public bool IsDirty
		{
		    get
			{
			    return Researches.Any(r => r.IsDirty);
		    }
			set 
			{
				foreach (Research research in Researches)
				{
					research.IsDirty = value;
				}
			}
	    }

        public static Project CreateProject()
        {
            return new Project
            {
                Name = "New project",
                Description = "Provide world peace",
                Path = @"C:\\test.raeproj",
                CustomInformation = new ObservableCollection<Tuple<string, string>>(),
                Researches = new ObservableCollection<Research>(),
            };
        }
    }
}